home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 15 / macformat_15.iso / Shareware Internet / Desarrolladores / gray image 2.1 / tiff.h < prev    next >
Text File  |  1995-05-30  |  11KB  |  243 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /*
  3.  ************************************************************************
  4.  *
  5.  *             Tag Image File Format (TIFF)
  6.  *
  7.  *   Class definitions for all important TIFF file data structures
  8.  *
  9.  * Tiff tag definitions were borrowed from:
  10.  *     > Copyright (c) 1988, 1990 by Sam Leffler.
  11.  *     > All rights reserved.
  12.  *    > 
  13.  *     > This file is provided for unrestricted use provided that this
  14.  *     > legend is included on all tape media and as a part of the
  15.  *     > software program in whole or part.  Users may copy, modify or
  16.  *     > distribute this file at will.
  17.  *    > 
  18.  *     > Based on Rev 5.0 from:
  19.  *        > Developer's Desk        Window Marketing Group
  20.  *        > Aldus Corporation        Microsoft Corporation
  21.  *        > 411 First Ave. South        16011 NE 36th Way
  22.  *        > Suite 200            Box 97017
  23.  *        > Seattle, WA  98104        Redmond, WA  98073-9717
  24.  *        > 206-622-5500            206-882-8080
  25.  * 
  26.  *
  27.  * $Id: tiff.h,v 2.0 1995/03/06 21:56:19 oleg Exp oleg $
  28.  *
  29.  ************************************************************************
  30.  */
  31.  
  32. #ifndef _TIFF_
  33. #define    _TIFF_
  34.  
  35. /*
  36.  *------------------------------------------------------------------------
  37.  *                TIFF file header
  38.  * It is always written at the very beginning of the TIFF file
  39.  */
  40.  
  41. class EndianIn;                // Opaque i/o classes
  42. class EndianOut;
  43.  
  44. class TIFFHeader
  45. {
  46.   unsigned short magic;        // magic number (defines byte order)
  47.   unsigned short version;    // TIFF version number
  48.   unsigned long  diroffset;    // byte offset to first directory
  49.  
  50.   enum { TIFF_BIGENDIAN = 0x4d4d,       // Interpretation of magic
  51.      TIFF_LITTLEENDIAN = 0x4949,
  52.      TIFF_VERSION = 42 };              // Interpretation of version
  53.  
  54. public:
  55.   TIFFHeader(void) : magic(TIFF_BIGENDIAN), version(TIFF_VERSION),
  56.              diroffset(sizeof(*this)) // Meaning the DIR follows 
  57.              {}                  // immediately after
  58.   TIFFHeader(EndianIn& file);
  59.   void write(EndianOut& file);
  60.   unsigned long directory_offset(void) const { return diroffset; }
  61. };
  62.  
  63. /*
  64.  *------------------------------------------------------------------------
  65.  *            TIFF Image File Directories 
  66.  * are comprised of a table of field descriptors of the form shown below.  
  67.  * The table is sorted in ascending order by tag.  The values associated 
  68.  * with each entry are disjoint and may appear anywhere in the file (so 
  69.  * long as they are placed on a word boundary).
  70.  *
  71.  * If the value is 4 bytes or less, then it is placed in the offset field 
  72.  * to save space.  If the value is less than 4 bytes, it is left-justified 
  73.  * in the offset field.
  74.  */
  75.  
  76. class TIFFDirEntry
  77. {
  78. public:
  79.   unsigned short tag;        // see below
  80.   unsigned short type;        // data type; see below
  81.   unsigned long  count;        // number of items; length in spec
  82.   unsigned long  val_offset;    // byte offset to field data
  83.  
  84. protected:
  85.   TIFFDirEntry(void) {}            // For use from derived classes only
  86.  
  87. public:
  88.   enum DataType {
  89.     BYTE = 1,            // 8-bit unsigned integer
  90.     ASCII = 2,            // 8-bit bytes w/ last byte null
  91.     SHORT = 3,            // 16-bit unsigned integer
  92.     LONG = 4,            // 32-bit unsigned integer
  93.     RATIONAL = 5        // 64-bit fractional (numerator+denominator)
  94.     };
  95.  
  96. protected:
  97.   TIFFDirEntry(const short _tag, const DataType _type, const long _count,
  98.            const long _value)
  99.     : tag(_tag), type(_type), count(_count), val_offset(_value) {}
  100. };
  101.  
  102. /* Types as defined in the TIFF standard for SUN3 */
  103.  
  104. typedef unsigned char  TBYTE;         /* 8-bits */
  105. typedef unsigned char  TASCII;        /* 8-bits */
  106. typedef unsigned short TSHORT;        /* 16 bits */
  107. typedef unsigned int   TLONG;         /* 32 bits */
  108. typedef unsigned long  TRATIONAL;     /* 2 LONG's numerator : denominator  */
  109.  
  110. #define INFINITY  99999
  111.  
  112. /*
  113.  *------------------------------------------------------------------------
  114.  *                TIFF Tag Definitions
  115.  *
  116.  * Those marked with a + are obsoleted by revision 5.0
  117.  */
  118. #define    TIFFTAG_SUBFILETYPE        254    /* subfile data descriptor   */
  119. #define        FILETYPE_REDUCEDIMAGE    0x1    /* reduced resolution version*/
  120. #define        FILETYPE_PAGE        0x2    /* one page of many         */
  121. #define        FILETYPE_MASK        0x4    /* transparency mask         */
  122.  
  123. #define    TIFFTAG_OSUBFILETYPE        255    /* +kind of data in subfile  */
  124. #define        OFILETYPE_IMAGE        1    /* full resolution image data*/
  125. #define        OFILETYPE_REDUCEDIMAGE    2    /* reduced size image data   */
  126. #define        OFILETYPE_PAGE        3    /* one page of many         */
  127.  
  128. #define    TIFFTAG_IMAGEWIDTH        256    /* image width in pixels     */
  129. #define    TIFFTAG_IMAGELENGTH        257    /* image height in pixels    */
  130. #define    TIFFTAG_BITSPERSAMPLE        258    /* bits per channel (sample) */
  131.  
  132. #define    TIFFTAG_COMPRESSION        259    /* data compression technique*/
  133. #define        COMPRESSION_NONE        1    /* dump mode             */
  134. #define        COMPRESSION_CCITTRLE    2    /* CCITT modified Huffman RLE*/
  135. #define        COMPRESSION_CCITTFAX3    3    /* CCITT Group 3 fax encoding*/
  136. #define        COMPRESSION_CCITTFAX4    4    /* CCITT Group 4 fax encoding*/
  137. #define        COMPRESSION_LZW        5    /* Lempel-Ziv  & Welch         */
  138. #define        COMPRESSION_NEXT        32766    /* NeXT 2-bit RLE         */
  139. #define        COMPRESSION_CCITTRLEW    32771    /* #1 w/ word alignment      */
  140. #define        COMPRESSION_PACKBITS    32773    /* Macintosh RLE         */
  141. #define        COMPRESSION_THUNDERSCAN    32809    /* ThunderScan RLE          */
  142. #define        COMPRESSION_PICIO        32900    /* old Pixar picio RLE         */
  143. #define        COMPRESSION_SGIRLE        32901    /* Silicon Graphics RLE      */
  144.  
  145. #define    TIFFTAG_PHOTOMETRIC        262    /* photometric interpretation*/
  146. #define        PHOTOMETRIC_MINISWHITE    0    /* min value is white         */
  147. #define        PHOTOMETRIC_MINISBLACK    1    /* min value is black         */
  148. #define        PHOTOMETRIC_RGB        2    /* RGB color model         */
  149. #define        PHOTOMETRIC_PALETTE        3    /* color map indexed         */
  150. #define        PHOTOMETRIC_MASK        4    /* holdout mask             */
  151. #define        PHOTOMETRIC_DEPTH        32768    /* z-depth data             */
  152.  
  153. #define    TIFFTAG_THRESHHOLDING        263    /* +thresholding used on data*/
  154. #define        THRESHHOLD_BILEVEL        1    /* b&w art scan             */
  155. #define        THRESHHOLD_HALFTONE        2    /* or dithered scan         */
  156. #define        THRESHHOLD_ERRORDIFFUSE    3    /* usually floyd-steinberg   */
  157.  
  158. #define    TIFFTAG_CELLWIDTH        264    /* +dithering matrix width   */
  159. #define    TIFFTAG_CELLLENGTH        265    /* +dithering matrix height  */
  160. #define    TIFFTAG_FILLORDER        266    /* +data order within a byte */
  161. #define        FILLORDER_MSB2LSB        1    /* most significant -> least */
  162. #define        FILLORDER_LSB2MSB        2    /* least significant -> most */
  163.  
  164. #define    TIFFTAG_DOCUMENTNAME        269    /* name of doc. image is from*/
  165. #define    TIFFTAG_IMAGEDESCRIPTION    270    /* info about image         */
  166. #define    TIFFTAG_MAKE            271    /* scanner manufacturer name */
  167. #define    TIFFTAG_MODEL            272    /* scanner model name/number */
  168. #define    TIFFTAG_STRIPOFFSETS        273    /* offsets to data strips    */
  169.  
  170. #define    TIFFTAG_ORIENTATION        274    /* +image orientation         */
  171. #define        ORIENTATION_TOPLEFT        1    /* row 0 top, col 0 lhs         */
  172. #define        ORIENTATION_TOPRIGHT    2    /* row 0 top, col 0 rhs         */
  173. #define        ORIENTATION_BOTRIGHT    3    /* row 0 bottom, col 0 rhs   */
  174. #define        ORIENTATION_BOTLEFT        4    /* row 0 bottom, col 0 lhs   */
  175. #define        ORIENTATION_LEFTTOP        5    /* row 0 lhs, col 0 top      */
  176. #define        ORIENTATION_RIGHTTOP    6    /* row 0 rhs, col 0 top      */
  177. #define        ORIENTATION_RIGHTBOT    7    /* row 0 rhs, col 0 bottom   */
  178. #define        ORIENTATION_LEFTBOT        8    /* row 0 lhs, col 0 bottom   */
  179.  
  180. #define    TIFFTAG_SAMPLESPERPIXEL        277    /* samples per pixel         */
  181. #define    TIFFTAG_ROWSPERSTRIP        278    /* rows per strip of data    */
  182. #define    TIFFTAG_STRIPBYTECOUNTS        279    /* bytes counts for strips   */
  183. #define    TIFFTAG_MINSAMPLEVALUE        280    /* +minimum sample value     */
  184. #define    TIFFTAG_MAXSAMPLEVALUE        281    /* maximum sample value      */
  185. #define    TIFFTAG_XRESOLUTION        282    /* pixels/resolution in x    */
  186. #define    TIFFTAG_YRESOLUTION        283    /* pixels/resolution in y    */
  187.  
  188. #define    TIFFTAG_PLANARCONFIG        284    /* storage organization         */
  189. #define        PLANARCONFIG_CONTIG        1    /* single image plane          */
  190. #define        PLANARCONFIG_SEPARATE    2    /* separate planes of data   */
  191.  
  192. #define    TIFFTAG_PAGENAME        285    /* page name image is from   */
  193. #define    TIFFTAG_XPOSITION        286    /* x page offset of image lhs*/
  194. #define    TIFFTAG_YPOSITION        287    /* y page offset of image lhs*/
  195. #define    TIFFTAG_FREEOFFSETS        288    /* +byte offset to free block*/
  196. #define    TIFFTAG_FREEBYTECOUNTS        289    /* +sizes of free blocks     */
  197.  
  198. #define    TIFFTAG_GRAYRESPONSEUNIT    290    /* gray scale curve accuracy */
  199. #define        GRAYRESPONSEUNIT_10S    1    /* tenths of a unit         */
  200. #define        GRAYRESPONSEUNIT_100S    2    /* hundredths of a unit         */
  201. #define        GRAYRESPONSEUNIT_1000S    3    /* thousandths of a unit     */
  202. #define        GRAYRESPONSEUNIT_10000S    4    /* ten-thousandths of a unit */
  203. #define        GRAYRESPONSEUNIT_100000S    5    /* hundred-thousandths         */
  204. #define    TIFFTAG_GRAYRESPONSECURVE    291    /* gray scale response curve */
  205. #define    TIFFTAG_GROUP3OPTIONS        292    /* 32 flag bits             */
  206. #define        GROUP3OPT_2DENCODING    0x1    /* 2-dimensional coding         */
  207. #define        GROUP3OPT_UNCOMPRESSED    0x2    /* data not compressed         */
  208. #define        GROUP3OPT_FILLBITS        0x4    /* fill to byte boundary     */
  209. #define    TIFFTAG_GROUP4OPTIONS        293    /* 32 flag bits             */
  210. #define        GROUP4OPT_UNCOMPRESSED    0x2    /* data not compressed         */
  211. #define    TIFFTAG_RESOLUTIONUNIT        296    /* units of resolutions         */
  212. #define        RESUNIT_NONE        1    /* no meaningful units         */
  213. #define        RESUNIT_INCH        2    /* english             */
  214. #define        RESUNIT_CENTIMETER        3    /* metric             */
  215. #define    TIFFTAG_PAGENUMBER        297    /* page numbers of multi-page*/
  216. #define    TIFFTAG_COLORRESPONSEUNIT    300    /* color scale curve accuracy*/
  217. #define        COLORRESPONSEUNIT_10S    1    /* tenths of a unit         */
  218. #define        COLORRESPONSEUNIT_100S    2    /* hundredths of a unit         */
  219. #define        COLORRESPONSEUNIT_1000S    3    /* thousandths of a unit     */
  220. #define        COLORRESPONSEUNIT_10000S    4    /* ten-thousandths of a unit */
  221. #define        COLORRESPONSEUNIT_100000S    5    /* hundred-thousandths         */
  222.  
  223. #define    TIFFTAG_COLORRESPONSECURVE    301    /* RGB response curve         */
  224. #define    TIFFTAG_SOFTWARE        305    /* name & release         */
  225. #define    TIFFTAG_DATETIME        306    /* creation date and time    */
  226. #define    TIFFTAG_ARTIST            315    /* creator of image         */
  227. #define    TIFFTAG_HOSTCOMPUTER        316    /* machine where created     */
  228. #define    TIFFTAG_PREDICTOR        317    /* prediction scheme w/ LZW  */
  229. #define    TIFFTAG_WHITEPOINT        318    /* image white point         */
  230. #define    TIFFTAG_PRIMARYCHROMATICITIES    319    /* primary chromaticities    */
  231. #define    TIFFTAG_COLORMAP        320    /* RGB map for pallette image*/
  232. #define    TIFFTAG_BADFAXLINES        326    /* lines w/ wrong pixel count*/
  233. #define    TIFFTAG_CLEANFAXDATA        327    /* regenerated line info     */
  234. #define         CLEANFAXDATA_CLEAN        0    /* no errors detected          */
  235. #define         CLEANFAXDATA_REGENERATED    1    /* receiver regenerated lines*/
  236. #define         CLEANFAXDATA_UNCLEAN    2    /* uncorrected errors exist  */
  237. #define    TIFFTAG_CONSECUTIVEBADFAXLINES    328    /* max consecutive bad lines */
  238.  
  239.         /* tags 32995-32999 are private tags registered to SGI          */
  240. #define    TIFFTAG_MATTEING        32995    /* alpha channel is present  */
  241.  
  242. #endif /* _TIFF_ */
  243.